package com.yowasa.xiuxian.engine.travel;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.service.helper.UserHelper;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.List;

@Component
public class ChengTravel implements TravelInterface {
    @Autowired
    private UserHelper userHelper;
    @Override
    public int getType() {
        return 2;
    }
    @Override
    public String exec(UserBO userBO) {
        int days = RandomUtil.randomInt(10, 30);
        int getTravel = RandomUtil.randomInt(20, 30) * userBO.getUserAttr().getLuc() / 50;
        userBO.getUserConfig().setGold(userBO.getUserConfig().getGold() + getTravel);
        userHelper.lockUser(userBO,days,userBO.getName()+"正在历练中");
        String msg=RandomUtil.choice(msgList());
        return MessageFormat.format("{0},消耗{1}天获取了{2}摩拉", msg,days, getTravel);
    }

    private List<String> msgList() {
        return Lists.newArrayList(
                "你在城市的集市中倒腾点货，赚了点小钱",
                "你被一个本地土豪相中，护卫了其一段时间",
                "你发现了官府正在通缉的凡人，将其捕获获得了一定的赏金",
                "城主正在招募修仙之士帮忙清理城市周围的妖兽,你参与其中获得了一些工钱",
                "城中酒楼失火被你撞见，酒楼老板给了你一些钱感谢你帮忙救火"
        );
    }

}
